package com.hotel.service.Impl;

import com.hotel.dao.OrderDao;
import com.hotel.dao.TableDao;
import com.hotel.factory.BeanFactory;
import com.hotel.pojo.Table;
import com.hotel.pojo.TableStatus;
import com.hotel.service.TableService;

import java.text.ParseException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * Created by LinYaTing on 2018/11/24 23:07
 */
public class TableServiceImpl implements TableService {

    private TableDao tableDao = BeanFactory.getInstance("tableDao", TableDao.class);

    @Override
    public void save(Table table) {
        tableDao.save(table);
    }

    @Override
    public List<Table> findAll() {
        List<Table> tableList = tableDao.findAll();
        return tableList;
    }

    @Override
    public List<Table> findNoUseTable() {
        return tableDao.findNoUseTable(TableStatus.Free);
    }

    @Override
    public List<Table> findTableByName(String tableName) {
        return tableDao.findTableByName(tableName);
    }

    @Override
    public void update(Table table) {
        if (table.getTableStatus() == 0) {
            table.setTableStatus(1);
        }else if (table.getTableStatus() == 1) {
            table.setTableStatus(0);
        }
        tableDao.update(table);
    }

    @Override
    public void delete(int id) {
        tableDao.delete(id);
    }

    @Override
    public Table findById(Integer id) {
        return tableDao.findById(id);
    }
}
